let mix = require('laravel-mix');
let path = require('path');
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/assets/js/app.js', 'public/js').sourceMaps()
   .sass('resources/assets/sass/app.scss', 'public/css');
if (mix.config.production) {
    mix.version();
}

mix.webpackConfig({
    resolve: {
        alias: {
            'config': 'assets/js/config',
            'components': 'assets/js/components',
            'route': 'assets/js/route',
            'common': 'assets/js/common',
            'base': 'assets/js/base',
            'layout': 'assets/js/layout',
            'static': 'assets/js/static'
        },
        modules: [
            'node_modules',
            path.resolve(__dirname, "resources")
        ]
    },
});

let CompressionPlugin = require("compression-webpack-plugin");
mix.webpackConfig({
    plugins: [
        new CompressionPlugin({
            asset: '[path].gz[query]',
            algorithm: 'gzip',
            threshold: 10240,
            minRatio: 0.8
        })


    ]
});
